package clientClasses;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

public class Menu {
	private List<Category> categories;

	private static final Menu menu = new Menu();

	private Menu() {
		categories = new ArrayList<Category>();
	}

	public static Menu getInstance() {
		return menu;
	}

	public List<Category> getCategories() {
		return categories;
	}

	public void addCategory(Category c) {
		if (c != null)
			categories.add(c);
	}

	public JsonObject toJson() {
		JsonObject obj = new JsonObject();
		JsonArray arr = new JsonArray();
		for (Category c : categories) {
			arr.add(c.toJson());
		}
		obj.add("categories", arr);
		return obj;
	}
}
